<template>
  <div class="wrap">
    <div class="content ignore">
      <div class="menuBox">
        <div class="menu_item" v-for="(item,index) in arr" :key='index'>
          <div class="menu_title">
            <img :src="item.src" alt="">
            <div>{{item.name}}</div>
          </div>
          <div :class="items.meta.state == $route.meta.state?'selectMenu':'unselectMenu'" v-for="(items,indexs) in item.children"
           :key='indexs'
           @click="chengMenu(index,indexs,items)" v-if="indexs < 2 || levelShow">
            <div></div>
            <div>{{items.name}}</div>
          </div>          
        </div>
      </div>
      <div class="menu_content">
        <router-view></router-view>
      </div>
    </div>
    
  </div>
</template>
<script>
import {userInfo,updateUserInfo,upgrade} from '@/api/user';
import { getToken,removeToken } from '@/utils/auth' // 驗權
export default {
  data(){
    return{
      arr:[
        {
          src:require('@/assets/minep.png'),
          name:'我的賬戶',
          children:[
            {name:'個人資料',path:'/personal',meta:{state:1}},
            {name:'會員組織架構',path:'/tree',meta:{state:0}},
            {name:'地址管理',path:'/address',meta:{state:2}}
          ]
        },
        {
          src:require('@/assets/jiaoyi.png'),
          name:'交易管理',
          children:[
            {name:'我的訂單',path:'/purorder',meta:{state:3}},
            {name:'我的優惠券',path:'/myCoupon',meta:{state:4}},
            {name:'PV值明細',meta:{state:5}, path:'/pvDetails',},
            // {name:'我的職位',meta:{state:6},path:'/pvjob'},
            // {name:'我的PV',meta:{state:7},path:'/pvmine'},
            // {name:'我的團隊分成',meta:{state:8},path:'/pvteam'},
            // {name:'我的團隊人員分布情況',path:'/team_member',meta:{state:9}},
          ]
        },
        {
          src:require('@/assets/collectp.png'),
          name:'我的收藏',
          children:[
            {name:'收藏的商品',path:'/myCollect',meta:{state:10}},
            // {name:'收藏的商品',path:'/myCollect',meta:{state:10}},
          ]
        },

      ],
      selectOne:0,
      selectTwo:0,
      levelShow:false
    }
  },
  mounted(){
    this.getuser()
  },
  methods:{
    getuser(){
      userInfo({userId:getToken()}).then(response => {
        if(response.errno == 0){
          if(response.data.userLevel < 2){
            this.levelShow = false
          }else{
            this.levelShow = true
          }
        }else{
         
        }
      })
    },
    chengMenu(index,indexs,items){
      if(items.path=='/tree'){
        let routerData=this.$router.resolve({
          path:'/tree',
          // query:{
          //   url:row.prtPath
          // }
        })
        window.open(routerData.href,'_blank')
        return
      }
      this.selectOne = index
      this.selectTwo = indexs
      if(items.path){
        this.$router.push({path:items.path})
      }
    }
  }
}
// path:'/pvDetails',
</script>
<style scoped>
  .wrap{
    width: 100%;
    min-height: 100vh;
    box-sizing: border-box;
    background: #f5f5f5;
    padding-top: 30px;
  }
  .ignore.content{
    width: 1300px;
    display: flex;
    margin: 0px auto;
  }
  .menuBox{
    width: 320px;
    background: white;
  }
  .menu_item{
    width: 100%;
    box-sizing: border-box;
  }
  .menu_title{
    width: 100%;
    height: 57px;
    background: #FBF9F9;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    box-sizing: border-box;
    padding: 5px;
  }
  .menu_title>img{
    width: 22px;
    height: 24px;
    margin-right: 10px;
  }
  .menu_title>div{
    font-size: 16px;
    font-weight: normal;
    color: #333333;
    line-height: 57px;
  }
  .selectMenu{
    width: 100%;
    box-sizing: border-box;
    background: white;
    padding: 20px 30px;
    align-items: center;
    display: flex;
    cursor: pointer;
  }
  .selectMenu>div:nth-child(1){
    width: 2px;
    height: 44px;
    background: #BD9967;
  }
  .selectMenu>div:nth-child(2){
    width: 95%;
    text-align: center;
    font-size: 20px;
    font-weight: 400;
    color: #BD9967;
    /* white-space: nowrap; */
  }
  .unselectMenu{
    width: 100%;
    box-sizing: border-box;
    background: white;
    padding: 20px 30px;
    align-items: center;
    display: flex;
    cursor: pointer;
  }
  .unselectMenu>div:nth-child(1){
    width: 2px;
    height: 44px;
    background: transparent;
  }
  .unselectMenu>div:nth-child(2){
    width: 95%;
    text-align: center;
    font-size: 20px;
    font-weight: 400;
    color: #000000;
    /* white-space: nowrap; */
  }
  .menu_content{
    width: 77%;
    margin-left: 2%;
  }
</style>